<?php
/*ini_set('display_errors','1'); ini_set('display_startup_errors','1'); */
/*************************************************************************
Index module
----------------------------------------------------------------
Vnnavi CMS Project
Company: Ava Co., Ltd                                  
Email: kimque@ava.vn                                    
Last updated: 08/03/201
**************************************************************************/
$templateFile = "index.tpl.html";
if(!$template->is_cached($userTemplate.$templateFile)){
	#product
	$products_per_page = $siteConfigs->getProperty('products_per_page');
	include_once(ROOT_PATH."classes/dao/products.class.php");
	$products = new Products();
	include_once(ROOT_PATH."classes/dao/vote.class.php");
	$vote = new Vote();
	$desc = "";
	$cboWebLink = $request->element('cboWebLink', ">>");
	$arrSort = "";
	switch($cboWebLink){
		case ">>": 	$arrSort = array("price"=>"ASC");break;
		case "<<": 	$arrSort = array("price"=>"DESC");break;
		case "AZ": 	$arrSort = array("vn_name"=>"ASC");break;
		case "ZA": 	$arrSort = array("vn_name"=>"DESC");break;
		default: 	$arrSort = array("date_published"=>"DESC");
	}
	$template->assign('cboWebLink',$cboWebLink);
	$productsIndexItems = $products->getObjects(1, "status =1 AND home=1", $arrSort, $products_per_page );
	$template->assign('productsIndexItems',$productsIndexItems);
	$template->assign('products',$products);
	#end product
	
	// Code chung toan he thong
	include_once(ROOT_PATH."modules/framework.module.php");
	 
	$template->assign("isproduct",1);// sap xep product theo thu tu anpal
	$pageName = $messages['home'];
	$active='home';
	$template->assign('pageName',$pageName);
	$template->assign('active',$active);
	$template->assign('vote',$vote);
}